<?php
$page_title="Manage AntiVirus Subscription -  List";
include("includes/header.php");

$req_id=$_GET["req_id"];
$mode=$_GET["mode"];

if($mode=="edit") 	$reqInfo=@array_pop(qry_data("SELECT * FROM bkitc_product_subscription where rec_id=".$req_id));

?>				
<div class="fleft">
<ul class="subMenu">
<li><a href="edit_subav.php?mode=add">Add New </a></li>
<li><a href="sub_av_list.php?mode=result">Back to Subscriber List </a></li>
</ul>
</div>
<div class="cleardiv"></div>
	<div style="width:100%" class="content_bg">
	

<form action="edit_subav_pro.php?req_id=<?=$req_id?>" method="post" id="frmRegister" onsubmit="return validateForm(this)" >
<div class="fright"><i>* Required fields</i></div>
<div class="break"></div>
<? if($mode=="edit" && $reqInfo["req_status"]=="0") {?>
<input type="button" onclick="handleApproval(<?=$req_id?>)" value="Approve this Subscription" style="cursor:pointer;background:#008A00;color:#fff;font-weight:bold;border:1px dotted;padding:2px;"/>
<input type="hidden" name="req_status" id="req_status" value="0" />

<? } ?>
<? if($mode=="edit" && $reqInfo["req_status"]=="1") {?>
<span style="background:#fff;color:#008A00;font-weight:bold;border:1px dotted;padding:2px;">Status : Approved</span>
<? } ?>
<? if($mode=="edit") {?>
<div style="float:right">
<p>Requested Date : <?=$reqInfo["rec_created"]?>  | 
Last Modified  Date : <?=$reqInfo["last_updated"]?></p>
</div>
<? } ?>

  <table id="Regform" border="0" cellspacing="3" cellpadding="2" width="100%">

    <tbody>
	<tr><td colspan="2" class="section_head">Subscriber Information</td></tr>
	<tr>
	
        <td class="frmLabel">Subscriber Type *</td>

        <td>
          <input class="inputCheckbox" name="sub_from" id="rbSub_1" value="1" type="radio" checked="true"  onchange="toggleForm(this.checked,1)"/>
	<label for="rbSub_1">BK Centre</label>
          <input class="inputCheckbox" name="sub_from" id="rbSub_2" value="2" type="radio" onchange="toggleForm(this.checked,2)"/>
	<label for="rbSub_2">BK Member</label>
        

        </td>

      </tr>
      
      <tr id="tr1">
        <td class="frmLabel">Centre Reg.No&nbsp;*</td>
        <td><input class="txtbox" name="centre_reg_id" id="centre_reg_id" size="40" value="<?=$reqInfo["centre_reg_id"]?>" type="text" /></td>
      </tr>
      <tr id="tr2">
        <td class="frmLabel">Centre Name&nbsp;*</td>
        <td><input class="txtbox" name="centre_name" id="centre_name" size="40" value="<?=$reqInfo["centre_name"]?>" type="text" /></td>
      </tr>     
        <tr  id="tr3">
        <td class="frmLabel">Centre Email&nbsp;*</td>
        <td><input class="txtbox" name="centre_email" id="centre_email" size="40" value="<?=$reqInfo["centre_email"]?>" type="text" /></td>
      </tr>  
      <tr>
        <td class="frmLabel">Contact Name&nbsp;*</td>
        <td><input class="txtbox" name="contact_name" id="contact_name" size="40" value="<?=$reqInfo["contact_name"]?>" type="text" /></td>
      </tr>  
      
      <tr  id="tr4" style="display:none"> 
        <td class="frmLabel">BKITC Membership ID &nbsp;*</td>
        <td><input class="txtbox" name="contact_reg_id" id="contact_reg_id" size="40" value="<?=$reqInfo["contact_reg_id"]?>" type="text" /> (starts with BKITC******)</td>
      </tr>  

      <tr  id="tr5" style="display:none"> 
        <td class="frmLabel">Contact Email&nbsp;*</td>
        <td><input class="txtbox" name="contact_email" id="contact_email" size="40" value="<?=$reqInfo["contact_email"]?>" type="text" /></td>
      </tr>  
        <tr>
        <td class="frmLabel"> Mobile No&nbsp;*</td>
        <td><input class="txtbox" name="contact_mobile" id="contact_mobile" size="40" value="<?=$reqInfo["contact_mobile"]?>" type="text" /></td>
      </tr>  
        <tr id="tr6" > 
        <td class="frmLabel" valign="top">Address&nbsp;*</td>
      	<td>  <textarea class="txtarea" rows="4" cols="50" name="contact_address" id="contact_address"><?=$reqInfo["contact_address"]?></textarea></td>
      </tr>  
      <tr><td colspan="2" class="section_head">Payment Information </td></tr>
	
        <tr>
        <td class="frmLabel">No.of Subscription&nbsp;</td>
        <td><input class="txtbox" name="sub_count" id="sub_count" size="2" value="<?=$reqInfo["sub_count"]?>" type="text"  onkeypress="return allowNumbersOnly(event)"/></td>
      </tr> 
      
        <tr>
        <td class="frmLabel">Amount Paid&nbsp;</td>
        <td><input class="txtbox" name="amount" id="amount" size="6" value="<?=$reqInfo["amount"]?>" type="text" onkeypress="return allowNumbersOnly(event)" /> INR</td>
      </tr> 
      <tr>
        <td class="frmLabel">Payment Date*</td>
        <td>
        
        
         <script language="javascript">
         
         <?
						if($reqInfo["pay_date"]=="") 
							echo "DateInput('pay_date', true, 'YYYY-MM-DD')";
						else
							echo "DateInput('pay_date', true, 'YYYY-MM-DD','".$reqInfo['pay_date']."')";
	?>
         
         
         </script>
        
        </td>
      </tr> 
   
      
         <tr>
        <td class="frmLabel"  valign="top">Payment Info</td>
       	<td>  <textarea class="txtarea" rows="2" cols="50" name="pay_remarks" id="pay_remarks"><?=$reqInfo["pay_remarks"]?></textarea></td>

      </tr> 
         <tr>
        <td class="frmLabel" valign="top">Other Info/Notes</td>
	<td>  <textarea class="txtarea" rows="2" cols="50" name="user_notes" id="user_notes"><?=$reqInfo["user_notes"]?></textarea></td>
      </tr> 
       
  	 </tr> 
         <tr>
        <td class="frmLabel" valign="top">Admin Notes</td>
	<td>  <textarea class="txtarea" rows="2" cols="50" name="admin_notes" id="admin_notes"><?=$reqInfo["admin_notes"]?></textarea></td>
      </tr> 
    </tbody>
  </table>


&nbsp;
  <p align="center"><input value="Save Subscription" id="frmSubmit"  type="submit" class="button"/>  <input value=" Reset " 	name="reset" type="reset"  class="button"/></p>

</form>
</div>

<div style="margin-bottom:40px">

</div>


<script type="text/javascript">

function toggleForm(vState,vMode){

if(vState==true && vMode==1){


$("tr1").show();
$("tr2").show();
$("tr3").show();
$("tr6").show();
$("tr4").hide();
$("tr5").hide();


}
if(vState==true && vMode==2){


$("tr1").hide();
$("tr2").hide();
$("tr3").hide();
$("tr4").show();
$("tr5").show();
$("tr6").hide();

}


}
function validateForm(vFormObject){


	var validateEmail=true;
	var validatePhone=false;

	var msgPrefix=" ";
	var user_msg="";
	var emailfilter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

	
	if(vFormObject.sub_from[0].checked){
	
		if(vFormObject.centre_reg_id.value=="")
		user_msg= user_msg + wrap(msgPrefix + "Centre Reg.No cannot be empty. Please check.");
		
		if(vFormObject.centre_name.value=="")
		user_msg= user_msg + wrap(msgPrefix + "Centre Name cannot be empty. Please check.");
		
		if(vFormObject.centre_email.value=="")
		user_msg= user_msg + wrap(msgPrefix + "Centre Email cannot be empty. Please check.");
		

		if(vFormObject.contact_address.value=="")
		user_msg= user_msg + wrap(msgPrefix + "Centre Address cannot be empty. Please check.");
	
	}else
	{
	
		if(vFormObject.contact_reg_id.value=="")
		user_msg= user_msg + wrap(msgPrefix + "BKIT Membership Id cannot be empty. Please check.");
		
		if(vFormObject.contact_email.value=="")
		user_msg= user_msg + wrap(msgPrefix + "Email cannot be empty. Please check.");
	

		if(vFormObject.contact_address.value=="")
		user_msg= user_msg + wrap(msgPrefix + "Conaact Address cannot be empty. Please check.");
		
		
	
	}
	
	
		if(vFormObject.contact_name.value=="")
		user_msg= user_msg + wrap(msgPrefix + "Contact Name cannot be empty. Please check.");

		if(vFormObject.contact_mobile.value=="")
		user_msg= user_msg + wrap(msgPrefix + "Mobile no cannot be empty. Please check.");


	if(vFormObject.centre_email.value!="")
	{
	
		if (!emailfilter.test(vFormObject.centre_email.value)){
		
		user_msg = user_msg + wrap("Invalid Email address. Please check.");
		
		}
	}
	if(vFormObject.contact_email.value!="")
	{
	
		if (!emailfilter.test(vFormObject.contact_email.value)){
		
		user_msg = user_msg + wrap("Invalid Email address. Please check.");
		
		}
	}



	if(user_msg=="")
		return true;
	else
	{	alert(user_msg);
		return false;
	}
	
	
	

}
var fromSub='<?=$reqInfo["sub_from"]?>';

if(fromSub==2){

toggleForm(true,2);
$("rbSub_2").checked=true;

}

function handleApproval(vReqid){

if(confirm("This action will send out emails to the Vendor.\n\nAre you sure to approve this subscription?")){

$("req_status").value=1;
$("frmRegister").submit();


}


}
</script>

<? include("includes/footer.php");?>
